<body>
    <form method="post" action="">
        <div class="panel admin-panel">
            <div class="panel-head"><strong class="icon-reorder"> 文章管理</strong></div>
            <div class="padding border-bottom">
            </div>
            <table class="table table-hover text-center">
                <tr>
                    <th width="120">ID</th>
                    <th>分类</th>
                    <th>封面</th>
                    <th>标题</th>
                    <th>简介</th>
                    <th>内容</th>
                    <th>添加时间</th>
                    <th>作者</th>
                    <th>阅读量</th>
                    <th>操作</th>       
                </tr> 
                <?php foreach ($articlelist as $k => $rows): ?>
                    <tr style="height: 50px">
                        <td><?=$currentpage+$k+1?> </td>
                        <td>
                            <?php if($rows['tid']==1): ?>
                            常见问题
                            <?php else: ?>
                            实战经验
                            <?php endif; ?>
                        </td>
                        <td><img src="<?= base_url() ?><?= $rows['thumb'] ?>" width="50px" height="50px"></td>
                        <td><?= $rows['title'] ?></td>
                        <td><?= $rows['brief'] ?></td>  
                        <td><?= $rows['content'] ?></td>         
                        <td><?= $rows['createtime'] ?></td>
                        <td><?= $rows['author'] ?></td>
                        <td><?= $rows['readamount'] ?></td>
                        <td><div class="button-group"> <a class="button border-red" href="javascript:void(0)" onclick="return del(<?=$rows['id']?>)"><span class="icon-trash-o"></span> 删除</a> </div></td>
                    </tr>
                <?php endforeach; ?>
                <tr>
                    <td colspan="8"><div class="pagelist"> <?= $this->pagination->create_links() ?></div></td>
                </tr>
            </table>
        </div>
    </form>
    <script type="text/javascript">

        function del(id) {
            if (confirm("您确定要删除吗?")) {
                let url = "<?=site_url('article/del')?>";
                let jsonData = {
                    'id':id
                };
                $.post(url,jsonData,function(redata){
                    if(redata.errno=='666'){
                        window.location.href = '<?=site_url("article/lists/$currentpage")?>';
                    }
                },'json');
            }
        }

        $("#checkall").click(function () {
            $("input[name='id[]']").each(function () {
                if (this.checked) {
                    this.checked = false;
                } else {
                    this.checked = true;
                }
            });
        })

        function DelSelect() {
            var Checkbox = false;
            $("input[name='id[]']").each(function () {
                if (this.checked == true) {
                    Checkbox = true;
                }
            });
            if (Checkbox) {
                var t = confirm("您确认要删除选中的内容吗？");
                if (t == false)
                    return false;
            } else {
                alert("请选择您要删除的内容!");
                return false;
            }
        }

    </script>
</body></html>